<template>
  <div>
    <van-nav-bar
      fixed
      :title="title"
      left-arrow
      @click-left="$utils.back($route.path);"
    />
    <div class="has-top ">
      <div class="topDiv">
        <img src="@/assets/images/pay/topicon.png" style="width:100%;">
        <img src="@/assets/images/pay/successIcon.png" class="mt-32 mb-32" style="width: 176px; height: 176px;">
        <div class="fs-32 fw-b">支付成功！</div>
        <div class="btnlist">
          <div @click="goHome()">返回首页</div>
          <div @click="goto()">分享订单</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import contentSearch from 'components/contentSearch'
import noData from 'components/noData'
import productList from 'components/productList'
import datetimeFilter from 'components/datetimeFilter'
import { GetWriteoffRecordPage } from 'api/writeoff'
import { GetUserPageFromStore, GetStoreMemberTotal } from 'api/member'

import imgBox from 'components/imgBox'
import { 		GetCashierLog,
		UseScanQRPay,
		GetOrUpdatePayUser,
		GetCouponUpdatePayUser,
		UseCashPay,
		GetBankList,
		GetFillOrderPayType} from 'api/cashier'
import { getInitWebInfo} from 'api/web'
import {
		GetBusinessFunction
	} from "api/businessSetting.js"
export default {
  components: {
    contentSearch,
    noData,
    productList,
    datetimeFilter,
    imgBox
  },
  data() {
    return {
      bgWhite: true,
      searchVal: '',
      // 时间选择框显示
      timeStartSelect: false,
      timeEndSelect: false,
      GetWriteoffRecordPageRequest: {
        PageIndex: 1,
        PageSize: 10,
      },

      // 记录列表
      productList: [],

      // 滚动状态
      totalAmout: 0,
      scollRequest: true,
      end: false,
			title: '支付订单',
			type: 0,
      radio:'1',
      tradeno:'',
      data:{},
				paymentShow:false,
				userNumber: '',
				fromtype:null,
				domain:'',
				webinfo:{},
				payTicksTime:null,
				paytypelist:'',
				Userinfo:{},
				switchnum:1,
        xianjin:false,
        balance:false,
        orderId:'',
			HomeIndex: '',
      storeId:''

    }
  },
  created() {
      this.orderId = this.$route.query.orderId
		  this.storeId = sessionStorage.getItem('nav_store_id');
		  this.getInitWebInfo()
  },
  mounted() {

  },
  methods: {
    getInitWebInfo() {
			getInitWebInfo().then(res => {
				if (res) {
					this.HomeIndex = res.Data.HomeIndex
				}
			})
		},
    getinfo() {
      let path = '?tradeno=' + this.tradeno + '&status=1'
      GetCashierLog({tradeno:this.tradeno,status:1}).then(res => {
        console.log(res)
        if (res.State == 1) {
          this.data = res.Data;
          if(res.Data.PayUserId !=0){
            // this.GetPayUser();
          }
        }
      })
    },
    getwebinfo(){
      let path = '?domain=' + this.$LocalDomain
      getInitWebInfo(path).then(res => {
        if (res.State == 1) {
          this.webinfo = res.Data
        }
      })
    },
    GetPayType(){
      GetFillOrderPayType().then(res => {
        if (res.State==1) {
          this.paytypelist = res.Data
        } else {
          this.$toast(res.Msg)
        }
      })
    },
    getPayList(){
      let path = '?tradeNo='+this.tradeno
      GetBankList({tradeno:this.tradeno}).then(res => {
        if (res.State==1) {
          if(res.Data.length > 0){
            this.paymentShow = true
          }
        } else {
          this.$toast(res.Msg)
        }
      })
    },
    GetBusiness(){
      let path = '53'
      GetBusinessFunction(path).then(res => {
        if (res.State==1) {
          this.switchnum = res.Data[0].Value
        } else {
          this.$toast(res.Msg)
          
        }
      })
    },
    submit(){
      if(this.radio=="1"){
        this.xianjin = true
      }
      if(this.radio=="2"){
        this.balance = true
      }
    },
    save() {
      var that = this
      this.$toast.loading({
        message: '正在验证...',
      })
      let path = '?tradeNo=' + this.tradeno + '&totalMoney=' + this.data.TotalMoney
      UseCashPay({tradeNo:this.tradeno,totalMoney:this.data.TotalMoney}).then(res => {
        this.$toast.clear()
        if (res.State == 1) {
          this.$toast('收款成功')
          if(this.fromtype==1){
            //去订单成功页
            setTimeout(e => {

            }, 1000)
          }else{
            // setTimeout(e => {
            //   this.$router.go(-1);
            // }, 1000)
          }
        } else {
          this.$toast(res.Msg);
        }
      })
    },
    balancesave(){
      let that = this;
      this.$toast.loading({
        message: '正在验证...',
      })
      let path = '?tradeNo=' + this.tradeno + "&totpWord=''&userId="+this.data.PayUserId
      UseScanQRPay({tradeNo:this.tradeno,totpWord:'',userId:this.data.PayUserId}).then(res => {
        this.$toast.clear()
        console.log(res)
        if (res.State == 1) {
          this.$toast("收款成功！收款金额：" + this.data.TotalMoney + "元");
            //去订单成功页
            setTimeout(e => {
              // that.goUrl('/pages/success/index')
            }, 1000)
        } else {
          this.$toast(res.Msg);
        }
      })
    },
    payment(){
				//跳转线下支付页
		},
    goHome() {
			if (this.storeId) {
				window.location.href = this.$LocalDomain + '/m/retail/RetailPage?store_id=' + this.storeId
			} else {
				window.location.href = this.$LocalDomain + this.HomeIndex
			}
		},
    goto(){
      this.$router.replace({
        path: '/bills?orderId='+this.orderId
      })
    },
  }
}
</script>
<style lang="scss" scoped>
.van-hairline--bottom::after{
  border-bottom-width:0;
}
.color-red{
  color: #F1270C;
}
.tag{
  width: 64px;
  height: 32px;
  line-height: 32px;
  text-align: center;
  background: #FFF2F0;
  color: #F1270C;
  border-radius: 4px;

}
.priceTop{
  margin: 120px auto 36px auto;
  text-align: center;
}
.payList{
  margin: 0 24px;
  .paytitle{
    height: 96px;
    line-height: 96px;
    background: linear-gradient( 270deg, #FFFBFB 0%, #FFF3F3 100%);
    border-radius: 24px 24px 0px 0px;
    font-size: 32px;
    color: #1E1E1E;
    padding-left: 34px;
  }
}
.bor-ra{
    height: 88px;
    background: #EF1F1F;
    border-radius: 44px;
    border: 1px solid #EF1F1F;

  }
  .topDiv{
    margin: 48px 56px;
    background: #ffffff;
    text-align: center;
  }
  .btnlist{
    display: flex;
    justify-content: center;
    margin-top: 48px;
    padding-bottom: 40px;
    div{
      width: 240px;
      height: 80px;
      line-height: 80px;
      background: #FFFFFF;
      border-radius: 44px;
      border: 1px solid #666666;
      font-size: 30px;
      color: #666666;
      margin: 0 32px;
    }
  }
</style>
